package com.limespot.api;

import java.util.Collection;
import java.util.HashSet;

import junit.framework.TestCase;

abstract class LimeSpotTestCase extends TestCase {
	
	private User fakeUser;

	protected final String getUsername() {
		return "spudtrooper";
	}
	
	protected final Factory factory() {
		return Bootstrap.getFactory();
	}
	
	protected final User user() {
		return factory().newUser(getUsername());
	}
	
	protected final User fake() {
		if (fakeUser == null) {
			fakeUser = new User() {

				public Collection<User> getContacts() {
					Collection<User> res = new HashSet<User>();
			    res.add(factory().newUser("ajfischler"));
			    res.add(factory().newUser("leothekim"));
			    res.add(factory().newUser("emilyg"));
			    res.add(factory().newUser("dave"));
			    res.add(factory().newUser("tolsen"));					
					return res;
				}

				public String getLargeImageURL() {
					return "http://limespot.com/media/141/422,300,300,s,t.png";
				}

				public String getSmallImageURL() {
					return "http://limespot.com/media/141/422,30,30,s,t.png";
				}

				public String getTagline() {
					return "diving with christ";
				}

				public String getURL() {
					return "http://scuba-jesus.com";
				}

				public String getUsername() {
					return "spudtrooper";
				}

				public int compareTo(User that) {
					String n1 = this.getUsername();
					String n2 = that.getUsername();
					if (n1 == null) return -1;
					if (n2 == null) return +1;
					return n1.compareTo(n2);
				}

				public int getId() {
					return 141;
				}

				public String getName() {
					return "Jeffrey Palm";
				}

				public String getBio() {
					return "my bio";
				}				
			};
		}
		return fakeUser;
	}
}
